<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="custom-style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
	<div style="overflow: hidden;">
		<div style="height: 57px;min-width: 1039px;background-size: auto 100%;background:url('');">
			<img src="titleleft.png" style="float: left;"/>
			<img src="titleright.png" alt="" style="float: right;" />
		</div>
	</div>
<!-- 制作者 Doxygen 1.8.15 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>法律声明</span></a></li>
      <li><a href="_xE9_xA6_x96_xE9_xA1_xB5.html"><span>首页</span></a></li>
      <li><a href="_xE6_x9B_xB4_xE6_x96_xB0_xE8_xAE_xB0_xE5_xBD_x95.html"><span>更新记录</span></a></li>
      <li><a href="_xE7_x8E_xAF_xE5_xA2_x83_xE9_x85_x8D_xE7_xBD_xAE.html"><span>环境配置</span></a></li>
      <li><a href="_xE7_xBC_x96_xE7_xA8_x8B_xE5_xBC_x95_xE5_xAF_xBC.html"><span>编程引导</span></a></li>
      <li><a href="modules.html"><span>接口说明</span></a></li>
      <li><a href="annotated.html"><span>结构体定义</span></a></li>
      <li><a href="_xE7_x9B_xB8_xE6_x9C_xBA_xE5_x8F_x82_xE6_x95_xB0_xE8_x8A_x82_xE7_x82_xB9_xE8_xA1_xA8.html"><span>相机参数节点表</span></a></li>
      <li><a href="examples.html"><span>示例程序</span></a></li>
      <li><a href="_xE9_x94_x99_xE8_xAF_xAF_xE7_xA0_x81.html"><span>状态码</span></a></li>
      <li><a href="_xE5_xB8_xB8_xE8_xA7_x81_xE9_x97_xAE_xE9_xA2_x98.html"><span>常见问题</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Events.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>获取相机事件</p>
<p>该示例程序说明如何配置相机事件功能、如何注册事件回调以及如何在事件回调函数中处理获取到的事件信息。Event事件例如：ExposureEnd。</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;unistd.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;pthread.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;MvCameraControl.h&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// 等待用户输入enter键来结束取流或结束程序</span></div><div class="line"><span class="comment">// wait for user to input enter to stop grabbing or end the sample program</span></div><div class="line"><span class="keywordtype">void</span> PressEnterToExit(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> c;</div><div class="line">    <span class="keywordflow">while</span> ( (c = getchar()) != <span class="charliteral">&#39;\n&#39;</span> &amp;&amp; c != EOF );</div><div class="line">    fprintf( stderr, <span class="stringliteral">&quot;\nPress enter to exit.\n&quot;</span>);</div><div class="line">    <span class="keywordflow">while</span>( getchar() != <span class="charliteral">&#39;\n&#39;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> PrintDeviceInfo(<a name="_a0"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html">MV_CC_DEVICE_INFO</a>* pstMVDevInfo)</div><div class="line">{</div><div class="line">    <span class="keywordflow">if</span> (NULL == pstMVDevInfo)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;The Pointer of pstMVDevInfo is NULL!\n&quot;</span>);</div><div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">if</span> (pstMVDevInfo-&gt;<a name="a1"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#a3b26b1c9681dba57af81bdb7ed795575">nTLayerType</a> == <a name="a2"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#gae1780ad0d41bcd2e835ab81155b398e6">MV_GIGE_DEVICE</a>)</div><div class="line">    {</div><div class="line">        <span class="keywordtype">int</span> nIp1 = ((pstMVDevInfo-&gt;<a name="a3"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a name="a4"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a name="a5"></a><a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#aea1e6f183f4d5cf372af1add35691563">nCurrentIp</a> &amp; 0xff000000) &gt;&gt; 24);</div><div class="line">        <span class="keywordtype">int</span> nIp2 = ((pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#aea1e6f183f4d5cf372af1add35691563">nCurrentIp</a> &amp; 0x00ff0000) &gt;&gt; 16);</div><div class="line">        <span class="keywordtype">int</span> nIp3 = ((pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#aea1e6f183f4d5cf372af1add35691563">nCurrentIp</a> &amp; 0x0000ff00) &gt;&gt; 8);</div><div class="line">        <span class="keywordtype">int</span> nIp4 = (pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#aea1e6f183f4d5cf372af1add35691563">nCurrentIp</a> &amp; 0x000000ff);</div><div class="line"></div><div class="line">        <span class="comment">// ch:打印当前相机ip和用户自定义名字 | en:print current ip and user defined name</span></div><div class="line">        printf(<span class="stringliteral">&quot;Device Model Name: %s\n&quot;</span>, pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a name="a6"></a><a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#a0444c9bb101455ec9303a2c0cf9052c1">chModelName</a>);</div><div class="line">        printf(<span class="stringliteral">&quot;CurrentIp: %d.%d.%d.%d\n&quot;</span> , nIp1, nIp2, nIp3, nIp4);</div><div class="line">        printf(<span class="stringliteral">&quot;UserDefinedName: %s\n\n&quot;</span> , pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#aab5fcc9de5a7fa798f170a8453818cc5">stGigEInfo</a>.<a name="a7"></a><a class="code" href="struct_m_v___g_i_g_e___d_e_v_i_c_e___i_n_f_o.html#aae7ffce31c7dd8e1c98aab32776e5080">chUserDefinedName</a>);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#a3b26b1c9681dba57af81bdb7ed795575">nTLayerType</a> == <a name="a8"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#ga356c3a2b4efad3bea955ecb54e1632fe">MV_USB_DEVICE</a>)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Device Model Name: %s\n&quot;</span>, pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a name="a9"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#a3bea622a6d4adb297c2a8c99f28c54eb">stUsb3VInfo</a>.<a name="a10"></a><a class="code" href="struct_m_v___u_s_b3___d_e_v_i_c_e___i_n_f_o.html#a1fd78924df9302fb6421706ddb10c6db">chModelName</a>);</div><div class="line">        printf(<span class="stringliteral">&quot;UserDefinedName: %s\n\n&quot;</span>, pstMVDevInfo-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#ad8047fbdb096b8801b869f00db151c69">SpecialInfo</a>.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#a3bea622a6d4adb297c2a8c99f28c54eb">stUsb3VInfo</a>.<a name="a11"></a><a class="code" href="struct_m_v___u_s_b3___d_e_v_i_c_e___i_n_f_o.html#a5749014e9a3d16bdca2d0cfb9f1f7e16">chUserDefinedName</a>);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Not support.\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> __stdcall EventCallBack(<a name="_a12"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html">MV_EVENT_OUT_INFO</a> * pEventInfo, <span class="keywordtype">void</span>* pUser)</div><div class="line">{</div><div class="line">    <span class="keywordflow">if</span> (pEventInfo)</div><div class="line">    {</div><div class="line">        int64_t nBlockId = pEventInfo-&gt;<a name="a13"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#a9df6b2cca06c4fd0a4812cc037f1639e">nBlockIdHigh</a>;</div><div class="line">        nBlockId = (nBlockId &lt;&lt; 32) + pEventInfo-&gt;<a name="a14"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#a41ad25f1ab6f18ccfbf98a6781f9f636">nBlockIdLow</a>;</div><div class="line"></div><div class="line">        int64_t nTimestamp = pEventInfo-&gt;<a name="a15"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#a49956ae9753c62a986aab9d5fe55c770">nTimestampHigh</a>;</div><div class="line">        nTimestamp = (nTimestamp &lt;&lt; 32) + pEventInfo-&gt;<a name="a16"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#a2afc62303be6a9adc2bb042bb944263d">nTimestampLow</a>;</div><div class="line"></div><div class="line">        printf(<span class="stringliteral">&quot;EventName[%s], EventID[%d], BlockId[%lld], Timestamp[%lld]\n&quot;</span>, </div><div class="line">            pEventInfo-&gt;<a name="a17"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#a68c4512382aab7af7afead8077ce03cc">EventName</a>, pEventInfo-&gt;<a name="a18"></a><a class="code" href="struct_m_v___e_v_e_n_t___o_u_t___i_n_f_o.html#af2d4fb0624cf2c9879244dfa8ad2630e">nEventID</a>, nBlockId, nTimestamp);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> nRet = MV_OK;</div><div class="line">    <span class="keywordtype">void</span>* handle = NULL;</div><div class="line"></div><div class="line">    <span class="keywordflow">do</span> </div><div class="line">    {</div><div class="line">        <span class="comment">// ch:初始化SDK | en:Initialize SDK</span></div><div class="line">        nRet = <a name="a19"></a><a class="code" href="group___s_d_k_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga768544eb6e6435313dd99ee9cf92d59d">MV_CC_Initialize</a>();</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Initialize SDK fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:枚举设备 | en:Enum device</span></div><div class="line">        <a name="_a20"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html">MV_CC_DEVICE_INFO_LIST</a> stDeviceList;</div><div class="line">        memset(&amp;stDeviceList, 0, <span class="keyword">sizeof</span>(<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html">MV_CC_DEVICE_INFO_LIST</a>));</div><div class="line">        nRet = <a name="a21"></a><a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga88741869e2b3c12e47025e53e6a7b58b">MV_CC_EnumDevices</a>(<a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#gae1780ad0d41bcd2e835ab81155b398e6">MV_GIGE_DEVICE</a> | <a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#ga356c3a2b4efad3bea955ecb54e1632fe">MV_USB_DEVICE</a>, &amp;stDeviceList);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Enum Devices fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (stDeviceList.<a name="a22"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#a757ade91f37b0c95b768035d0ec07fdc">nDeviceNum</a> &gt; 0)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; stDeviceList.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#a757ade91f37b0c95b768035d0ec07fdc">nDeviceNum</a>; i++)</div><div class="line">            {</div><div class="line">                printf(<span class="stringliteral">&quot;[device %d]:\n&quot;</span>, i);</div><div class="line">                <a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html">MV_CC_DEVICE_INFO</a>* pDeviceInfo = stDeviceList.<a name="a23"></a><a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#ac8a3f91cd4d9e7f09ff4abaac031dffc">pDeviceInfo</a>[i];</div><div class="line">                <span class="keywordflow">if</span> (NULL == pDeviceInfo)</div><div class="line">                {</div><div class="line">                    <span class="keywordflow">break</span>;</div><div class="line">                } </div><div class="line">                PrintDeviceInfo(pDeviceInfo);            </div><div class="line">            }  </div><div class="line">        } </div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Find No Devices!\n&quot;</span>);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        printf(<span class="stringliteral">&quot;Please Intput camera index: &quot;</span>);</div><div class="line">        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nIndex = 0;</div><div class="line">        scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;nIndex);</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (nIndex &gt;= stDeviceList.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#a757ade91f37b0c95b768035d0ec07fdc">nDeviceNum</a>)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Intput error!\n&quot;</span>);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:选择设备并创建句柄 | en:Select device and create handle</span></div><div class="line">        nRet = <a name="a24"></a><a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#gaf10f0644caa6d4dd39fd8c14f8736153">MV_CC_CreateHandle</a>(&amp;handle, stDeviceList.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#ac8a3f91cd4d9e7f09ff4abaac031dffc">pDeviceInfo</a>[nIndex]);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Create Handle fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:打开设备 | en:Open device</span></div><div class="line">        nRet = <a name="a25"></a><a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga308c9a9869be7a457d27aadd94ce57dd">MV_CC_OpenDevice</a>(handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Open Device fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)</span></div><div class="line">        <span class="keywordflow">if</span> (stDeviceList.<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o___l_i_s_t.html#ac8a3f91cd4d9e7f09ff4abaac031dffc">pDeviceInfo</a>[nIndex]-&gt;<a class="code" href="struct_m_v___c_c___d_e_v_i_c_e___i_n_f_o.html#a3b26b1c9681dba57af81bdb7ed795575">nTLayerType</a> == <a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#gae1780ad0d41bcd2e835ab81155b398e6">MV_GIGE_DEVICE</a>)</div><div class="line">        {</div><div class="line">            <span class="keywordtype">int</span> nPacketSize = <a name="a26"></a><a class="code" href="group___gig_e_xE7_x9B_xB8_xE6_x9C_xBA.html#ga9df4e6a7acbd6e6a6952e01949efc18b">MV_CC_GetOptimalPacketSize</a>(handle);</div><div class="line">            <span class="keywordflow">if</span> (nPacketSize &gt; 0)</div><div class="line">            {</div><div class="line">                nRet = <a name="a27"></a><a class="code" href="group___xE5_xBA_x9F_xE5_xBC_x83_xE6_x8E_xA5_xE5_x8F_xA3.html#ga6323cf15f3319cb2b23646c1ca03c166">MV_CC_SetIntValue</a>(handle,<span class="stringliteral">&quot;GevSCPSPacketSize&quot;</span>,nPacketSize);</div><div class="line">                <span class="keywordflow">if</span>(nRet != MV_OK)</div><div class="line">                {</div><div class="line">                    printf(<span class="stringliteral">&quot;Warning: Set Packet Size fail nRet [0x%x]!\n&quot;</span>, nRet);</div><div class="line">                }</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                printf(<span class="stringliteral">&quot;Warning: Get Packet Size fail nRet [0x%x]!\n&quot;</span>, nPacketSize);</div><div class="line">            }</div><div class="line">        }</div><div class="line">        </div><div class="line">        nRet = <a name="a28"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga15a8abe28a1c5a53e10d115c7def4089">MV_CC_SetEnumValue</a>(handle, <span class="stringliteral">&quot;TriggerMode&quot;</span>, <a name="a29"></a><a class="code" href="group___xE7_xB1_xBB_xE5_x9E_x8B_xE5_xAE_x9A_xE4_xB9_x89.html#gga0c8acd46a8855d93c57b0921b4f9bde9a673e3eb298399f4f80866b97e8f2704c">MV_TRIGGER_MODE_OFF</a>);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Set Trigger Mode fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:开启Event | en:Set Event of ExposureEnd On</span></div><div class="line">        nRet = <a name="a30"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga920d6f7c5547a7099feb85c6e9e738ab">MV_CC_SetEnumValueByString</a>(handle,<span class="stringliteral">&quot;EventSelector&quot;</span>,<span class="stringliteral">&quot;ExposureEnd&quot;</span>);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Set Event Selector fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>; </div><div class="line">        }</div><div class="line"></div><div class="line">        nRet = <a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga920d6f7c5547a7099feb85c6e9e738ab">MV_CC_SetEnumValueByString</a>(handle,<span class="stringliteral">&quot;EventNotification&quot;</span>,<span class="stringliteral">&quot;On&quot;</span>);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Set Event Notification fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>; </div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:注册事件回调 | en:Register event callback</span></div><div class="line">        nRet = <a name="a31"></a><a class="code" href="group___xE4_xBA_x8B_xE4_xBB_xB6_xE5_x8F_x8A_xE5_xBC_x82_xE5_xB8_xB8.html#gaef606cb8e2e0bf249ec80ef1255e834b">MV_CC_RegisterEventCallBackEx</a>(handle, <span class="stringliteral">&quot;ExposureEnd&quot;</span>, EventCallBack, handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Register Event CallBack fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>; </div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:开始取流 | en:Start grab image</span></div><div class="line">        nRet = <a name="a32"></a><a class="code" href="group___xE5_x9B_xBE_xE5_x83_x8F_xE9_x87_x87_xE9_x9B_x86.html#ga78728211c47c6f118110fde635d6ac69">MV_CC_StartGrabbing</a>(handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Start Grabbing fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        PressEnterToExit();</div><div class="line"></div><div class="line">        <span class="comment">// ch:停止取流 | en:Stop grab image</span></div><div class="line">        nRet = <a name="a33"></a><a class="code" href="group___xE5_x9B_xBE_xE5_x83_x8F_xE9_x87_x87_xE9_x9B_x86.html#gae5d7f4ae46a53851f104e26fa449ab06">MV_CC_StopGrabbing</a>(handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Stop Grabbing fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:关闭设备 | en:Close device</span></div><div class="line">        nRet = <a name="a34"></a><a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga33853bd328f46492102246ca8b645d57">MV_CC_CloseDevice</a>(handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Close Device fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// ch:销毁句柄 | en:Destroy handle</span></div><div class="line">        nRet = <a name="a35"></a><a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga0f74372a22e8a19fa7e21dad45070428">MV_CC_DestroyHandle</a>(handle);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Destroy Handle fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">        handle = NULL;</div><div class="line">    } <span class="keywordflow">while</span> (0);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (handle != NULL)</div><div class="line">    {</div><div class="line">        <a class="code" href="group___xE7_x9B_xB8_xE6_x9C_xBA_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga0f74372a22e8a19fa7e21dad45070428">MV_CC_DestroyHandle</a>(handle);</div><div class="line">        handle = NULL;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// ch:反初始化SDK | en:Finalize SDK</span></div><div class="line">    <a name="a36"></a><a class="code" href="group___s_d_k_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#gafa1820a0da8671fc6f77dc9a7dfa69d3">MV_CC_Finalize</a>();</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;exit.\n&quot;</span>);</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<div class="footer" style="text-align: right;">
	<hr/>
	<small></small>
</div>
<script>
	// 当前选中的菜单
	var currentMenuItem = document.querySelector('.tablist > li.current > a')
	if (currentMenuItem) { // 子菜单情况
	  window.parent.postMessage({
		navHref: currentMenuItem.href
	  }, '*')
	} else {
	  window.parent.postMessage({
		url: window.location.href
	  }, '*')
	}
  </script>
</body>
</html>